<?php

use App\Models\Category;
use App\Models\Platform;
use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        // $this->call(UsersTableSeeder::class);
        $this->initCategory();
        $this->initPlatform();
    }

    private function initCategory()
    {
        $categories = [
            [
                'name'  => 'CS:GO',
                'url'   => '/channel/csgo',
                'title' => '反恐精英：全球行动'
            ],
            [
                'name'  => 'DOTA2',
                'url'   => '/channel/dota2',
                'title' => '刀塔2'
            ]
        ];
        foreach ($categories as $category) {
            Category::create($category);
        }
    }

    private function initPlatform()
    {
        $platforms = [
            [
                'name'    => 'douyu',
                'title'   => '斗鱼',
                'api_url' => 'http://open.douyucdn.cn/api/RoomApi/live/'
            ],
            [
                'name'    => 'huomao',
                'title'   => '火猫',
                'api_url' => 'https://www.huomao.com/channels/channel.json?page=1&page_size=120&game_url_rule='
            ],
            [
                'name'    => 'panda',
                'title'   => '熊猫',
                'api_url' => 'https://www.panda.tv/ajax_sort?pageno=1&pagenum=120&order=top&classification='
            ],
            [
                'name'    => 'huya',
                'title'   => '虎牙',
                'api_url' => 'https://www.huya.com/cache10min.php?m=Live&do=getProfileRecommendList&gid='
            ],

        ];
        foreach ($platforms as $platform) {
            Platform::create($platform);
        }
    }
}
